
package lesson3.slides.xml.jaxb;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import lesson3.slides.xml.jaxb.generated.GreetingListType;
import lesson3.slides.xml.jaxb.generated.GreetingType;
import lesson3.slides.xml.jaxb.generated.ObjectFactory;

public class UsingGeneratedOutput {

    public static void main(String[] args) throws JAXBException {
       ObjectFactory of = new ObjectFactory();
        GreetingListType grList =
                of.createGreetingListType();
        GreetingType g = of.createGreetingType();
        g.setText("Bonjour");
        g.setLanguage("fr");
        grList.getGreeting().add(g);
        g = of.createGreetingType(); // create a second entry
        g.setText("Gday");
        g.setLanguage("en_AU");
        grList.getGreeting().add(g);
        JAXBElement<GreetingListType> gl =
                of.createGreetings(grList);
        JAXBContext jc =
                JAXBContext.newInstance("lesson3.slides.xml.jaxb.generated");
        Marshaller m = jc.createMarshaller();
        m.marshal(gl, System.out);

    }
}
